package com.tianqu.tms.dao;

import java.sql.PreparedStatement;
import java.sql.SQLException;

import com.tianqu.tms.core.exception.TmsDaoException;
import com.tianqu.tms.dto.TransferTicketdInfoDto;

public class TransferTicketdInfoDaoImp extends TmsDao implements TransferTicketdInfoDao {

	protected TransferTicketdInfoDaoImp() throws TmsDaoException {
		super();
	}


	@Override
	public long insertTransferTicketdInfo(TransferTicketdInfoDto dto) throws TmsDaoException {
		PreparedStatement ps = null;

		try {
			StringBuffer sql = new StringBuffer("INSERT INTO ");
			sql.append(TmsTableNames.TMS_TRANSFER_TICKETD_INFO);
			sql.append(" (  ");
			sql.append(" serial, ");
			sql.append(" licensePlate, ");
			sql.append(" vin, ");
			sql.append(" modelCode, ");
			sql.append(" vendorCode, ");
			sql.append(" carType, ");
			sql.append(" carUse, ");
			sql.append(" registerCardNo, ");
			sql.append(" carMarketInName, ");
			sql.append(" marketName, ");
			sql.append(" taxpayerNo, ");
			sql.append(" address, ");
			sql.append(" bank, ");
			sql.append(" phone, ");
			sql.append(" transNo, ");
			sql.append(" carOwner, ");
			sql.append(" carOwnerIdCardNo, ");
			sql.append(" ownerPhone, ");
			sql.append(" ownerAddress, ");
			sql.append(" newCarOwner, ");
			sql.append(" newCarOwnerIdCardNo, ");
			sql.append(" newOwnerPhone, ");
			sql.append(" newOwnerAddress, ");
			sql.append(" price, ");
			sql.append(" checkUserid, ");
			sql.append(" insertUserid, ");
			sql.append(" insertTime ");
			sql.append("  ) VALUES ( ");
			sql.append(" ?,?,?,?,?,?,?,?,?,?,");
			sql.append(" ?,?,?,?,?,?,?,?,?,?,");
			sql.append(" ?,?,?,?,?,?,now()  )");
			ps = conn.prepareStatement(sql.toString());
			int i = 0;
			ps.setString(++i, dto.getSerial());
			ps.setString(++i, dto.getLicensePlate());
			ps.setString(++i, dto.getVin());
			ps.setString(++i, dto.getModelCode());
			ps.setString(++i, dto.getVendorCode());
			ps.setString(++i, dto.getCarType());
			ps.setString(++i, dto.getCarUse());
			ps.setString(++i, dto.getRegisterCardNo());
			ps.setString(++i, dto.getCarMarketInName());
			ps.setString(++i, dto.getMarketName());
			ps.setString(++i, dto.getTaxpayerNo());
			ps.setString(++i, dto.getAddress());
			ps.setString(++i, dto.getBank());
			ps.setString(++i, dto.getPhone());
			ps.setString(++i, dto.getTransNo());
			ps.setString(++i, dto.getCarOwner());
			ps.setString(++i, dto.getCarOwnerIdCardNo());
			ps.setString(++i, dto.getOwnerPhone());
			ps.setString(++i, dto.getOwnerAddress());
			ps.setString(++i, dto.getNewCarOwner());
			ps.setString(++i, dto.getNewCarOwnerIdCardNo());
			ps.setString(++i, dto.getNewOwnerPhone());
			ps.setString(++i, dto.getNewOwnerAddress());
			ps.setInt(++i, dto.getPrice());
			ps.setString(++i, dto.getCheckUserid());
			ps.setInt(++i, dto.getInsertUserid());
			return ps.executeUpdate();
		} catch (SQLException e) {
			throw new TmsDaoException(e.toString());
		} finally {
			super.close(ps);
		}
	}
}
